# Copyright 2001-2007 by iNeed,Inc. All Rights Reserved.

"""
use cases:

"""
import sys, os, time, string,android,logging
#/sdcard/com.googlecode.pythonforandroid/extras/python
"""
E:\kingCloud\ineed-taxi\code\game>adb push ../iNeedProjectVC/iNeedProjectVC/test
p4a.py /sdcard/com.googlecode.pythonforandroid/extras/python/

adb pull /sdcard/ineed/log.txt ./log.txt
"""
__author__  = "Number Huang<huang.bafeng@iNeed.com>"
__status__  = "developing"
__version__ = "0.1108.13.1"
logfile = '/sdcard/ineed/log.txt'#log.txt'
formatter = logging.Formatter('%(message)s')
fileHandler = logging.FileHandler(filename=logfile,mode='w')
fileHandler.setFormatter(formatter)
console = logging.StreamHandler()
console.setFormatter(formatter)
logger = logging.getLogger('')
logger.addHandler(fileHandler)
logger.addHandler(console)
logger.setLevel(logging.DEBUG)
"""
var values = [
['airplane', document.getElementById('airplane_mode').value],
['wifi', document.getElementById('wifi_on').value],
['brightness', document.getElementById('brightness').value],
['volume', document.getElementById('volume').value],
];
var q = '?';
for (i=0;i<values.length;i++){
var k = values[i][0];
var v = values[i][1];
if (q != '?'){
q = q + '&';
}
q = q + k + '=' + v;
}
droid.postEvent('save', q);
"""

def test1():
     logger.debug("before create")
     droid = android.Android()
     try:
         logger.debug("before show")
         droid.webViewShow('file:///sdcard/ineed/test1.htm')
         while True:
            logger.debug("before wait")
            result = droid.eventWaitFor('EVT_CONFIRM').result
            logger.debug("the return value is %s"%result['data'])

     except:
        logger.exception("error exit")

def test2():
    path1 = '/sdcard/ineed/'
    if path1 not in sys.path:
        sys.path.append(path1)
    import driver
if __name__=="__main__":

    test2()